package leetcode_cn;

import java.util.Collections;

/**
 * 反转字符串
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-07 16:38
 */
public class ReverseString {


    public String solution(String s){
        if (s == null || s.length() <= 1) return s;
        char[] array = s.toCharArray();
        int len = array.length;
        char[] res = new char[len];
        for (int i = 0; i < len; i++) {
            res[len-i-1] = array[i];
        }

        return String.valueOf(res);
    }


    public static void main(String[] args) {
        System.out.println(new ReverseString().solution("hello"));
        System.out.println(new ReverseString().solution("A man, a plan, a canal: Panama"));
    }
}
